package tools.timezone;

import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

public class TZ {
	
	public static Date toNYTime(Date date){
		TimeZone cnTZ = TimeZone.getDefault();
		TimeZone nyTZ = TimeZone.getTimeZone("America/New_York");
		Calendar cnCal = Calendar.getInstance(cnTZ);
		cnCal.setTime(date);
		System.out.println(cnCal.get(Calendar.HOUR_OF_DAY));
		cnCal.setTimeZone(nyTZ);
		System.out.println(cnCal.get(Calendar.HOUR_OF_DAY));
		return cnCal.getTime();
		//return date + (nyTZ.getOffset(date) - cnTZ.getOffset(date));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Date nyNow = toNYTime(new Date());
		System.out.println(nyNow.getHours());
	}

}
